﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AnimaGestionPersonnage.Utilities
{
    /// <summary>
    /// Structure de base pour les competences quelconques
    /// </summary>
    public class Skill
    {
        public String name { get; set; }
        public int otherBonus { get; set; }
        public SkillSet skillSet { get; set; }

        public Skill()
        {
        }

        public Skill(string n)
        {
            name = n;
        }

        public override String ToString()
        {
            return name;
        }
    }

    public class BasicSkill : Skill, IEquatable<BasicSkill>, IComparer<BasicSkill>, IComparable<BasicSkill>
    {
        public TypeSkill type { get; set; }
        public int tP { get; set; }

        public BasicSkill()
            : base()
        {
        }

        public BasicSkill(string n)
            : base(n)
        {
        }

        public bool Equals(BasicSkill ohterSkill)
        {
            return name.Equals(ohterSkill.name);
        }

        /// <summary>
        /// Compare 2 skill et les place dans l'ordre suivant:
        /// 1 - SkillSet
        /// 2 - TypeSkill
        /// 3 - Alphabetique
        /// </summary>
        /// <param name="thisSkill"></param>
        /// <param name="otherSkill"></param>
        /// <returns>la valeur position std des Compare(o,o)</returns>
        public int Compare(BasicSkill thisSkill, BasicSkill otherSkill)
        {
            int tempRet = 0;

            tempRet = thisSkill.name.CompareTo(otherSkill.name);

            tempRet += (((int)thisSkill.type - (int)otherSkill.type) * 10);

            tempRet += (((int)thisSkill.skillSet - (int)otherSkill.skillSet) * 100);

            return tempRet;
        }

        public int CompareTo(BasicSkill other)
        {
            return this.Compare(this, other);
        }
    }

    /// <summary>
    /// Structure pour le stockage d'une compétence primaire
    /// </summary>
    public class PrimarySkill : BasicSkill, IEquatable<PrimarySkill>, IComparer<PrimarySkill>, IComparable<PrimarySkill>
    {
        public Stats stat { get; set; }

        public PrimarySkill()
            : base()
        {
        }

        public PrimarySkill(string n)
            : base(n)
        {
        }

        public bool Equals(PrimarySkill ohterSkill)
        {
            return name.Equals(ohterSkill.name);
        }

        /// <summary>
        /// Compare 2 skill et les place dans l'ordre suivant:
        /// 1 - SkillSet
        /// 2 - TypeSkill
        /// 3 - Alphabetique
        /// </summary>
        /// <param name="thisSkill"></param>
        /// <param name="otherSkill"></param>
        /// <returns>la valeur position std des Compare(o,o)</returns>
        public int Compare(PrimarySkill thisSkill, PrimarySkill otherSkill)
        {
            int tempRet = 0;

            tempRet = thisSkill.name.CompareTo(otherSkill.name);

            tempRet += (((int)thisSkill.type - (int)otherSkill.type) * 10);

            tempRet += (((int)thisSkill.skillSet - (int)otherSkill.skillSet) * 100);

            return tempRet;
        }

        public int CompareTo(PrimarySkill other)
        {
            return this.Compare(this, other);
        }
    }

    /// <summary>
    /// Un structure pour le stockage d'une comptence secondaire
    /// </summary>
    public class SecondarySkill : PrimarySkill, IEquatable<SecondarySkill>, IComparer<SecondarySkill>, IComparable<SecondarySkill>
    {
        public int naturalBonus { get; set; }

        public SecondarySkill()
            : base()
        {
        }

        public SecondarySkill(string n)
            : base(n)
        {
        }

        public bool Equals(SecondarySkill ohterSkill)
        {
            return name.Equals(ohterSkill.name);
        }

        /// <summary>
        /// Compare 2 skill et les place dans l'ordre suivant:
        /// 1 - SkillSet
        /// 2 - TypeSkill
        /// 3 - Alphabetique
        /// </summary>
        /// <param name="thisSkill"></param>
        /// <param name="otherSkill"></param>
        /// <returns>la valeur position std des Compare(o,o)</returns>
        public int Compare(SecondarySkill thisSkill, SecondarySkill otherSkill)
        {
            int tempRet = 0;

            tempRet = thisSkill.name.CompareTo(otherSkill.name);

            tempRet += (((int)thisSkill.type - (int)otherSkill.type) * 10);

            tempRet += (((int)thisSkill.skillSet - (int)otherSkill.skillSet) * 100);

            return tempRet;
        }

        public int CompareTo(SecondarySkill other)
        {
            return this.Compare(this, other);
        }
    }
}
